const techAbout = {
    getAboutInfo: function () {
        let _this = this;
        ajax_get(host + '/ajax/aboutUs',
            true,
            {},
            (res) => {
                res = JSON.parse(res)
                console.log(res)
                if (res.about) {
                    const { about, advantage, partner, patent, service } = res
                    let re = new RegExp("&lt;p&gt;", "g")
                    let re2 = new RegExp("&lt;/p&gt;", "g")
                    let re3 = new RegExp("&amp;nbsp;", "g")
                    let newStr = about.content.replace(re, "<p>")
                    newStr = newStr.replace(re2, "</p>")
                    newStr = newStr.replace(re3, " ")
                    $(".about1-read").html(newStr);
                    $(".about1-read-img img").attr("src", about.image);
                    // 优势
                    $(".about2-banner-img img").attr("src", advantage.background)
                    _this.renderHtml(".about2-icon-box", advantage.data, "advantage")
                    // 服务
                    _this.renderHtml(".she-list-ul", service, "service")
                    // 专利证书
                    $(".about-box4-bg img").attr("src", patent.background)
                    _this.renderHtml(".patent-container", patent.data, "patent")
                    _this.renderHtml(".section-part-box", partner, 'partner')
                }
            },
            err => {
                console.log(err)
            }
        );
    },
    renderHtml: function (selector, data, tag) {
        if (data && data.length > 0) {
            if (tag == 'advantage') {
                let str = ''
                data.forEach(item => {
                    str += `<div class="about2-icon-li">
                        <img src="${item.logo}" alt="">
                        <span class="line"></span>
                        <span>${item.title}</span>
                        <span>${item.text}</span>
                    </div>`
                });
                $(selector).html(str)
            } else if (tag == 'service') {
                let str = ''
                data.forEach((item, index) => {
                    str += `<div class="she-list-li wow fadeInUp d2">
                    <div class="imgJsWrap">
                        <div class="she-list-img img-black">
                            <img src="${item.image}" alt="">
                        </div>
                        <div class="she-list-a"><em>0${index + 1}</em>${item.title}</div>
                        <div class="she-list-desc">
                            ${item.text}</div>
                    </div>
                </div>`
                });
                $(selector).html(str)
            } else if (tag == 'patent') {
                let str = ''
                data.forEach((item) => {
                    str += `<div class="swiper-slide">
                    <div class="fzlc-slide">
                        <img src="${item.image}" alt="">
                    </div>
                </div>`
                });
                $(selector).html(str)
            }else if (tag == 'partner') {
                let str = ''
                if(data && data.length > 0)
                data.forEach(item => {
                    str += ` <div class="swiper-slide">
                    <div class="section-part ">
                        <img src="${item.image}" alt="">
                    </div>
                </div>`
                })
    
                $(selector).html(str)
            } 
        }
    }
}


$(function () {
    common.init()
    common.fzlcTab()
    common.maoAnimate()
    common.partTab()
    common.aboutNav()
    common.getPhoneInfo()
    common.getBanner("about")
    techAbout.getAboutInfo()
    common.getFootProductCatList()
    common.getFootInfo()
})